package cn.lili.controller.promotion;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dto.search.BoxSearchParams;
import cn.lili.modules.promotion.entity.vos.BoxOptionVO;
import cn.lili.modules.promotion.entity.vos.BoxWinningRecordVO;
import cn.lili.modules.promotion.service.BoxLotteryTicketService;
import cn.lili.modules.promotion.service.BoxWinningRecordService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;

/**
 * 中奖记录管理
 */
@RestController
@AllArgsConstructor
@RequestMapping("/promotion/box/winning/record")
public class BoxWinningRecordController {

    private BoxWinningRecordService boxWinningRecordService;

    /**
     * 获取中奖记录，列表分页
     *
     * @param boxSearchParams 搜索条件
     * @return 结果
     */
    @GetMapping("/page")
    public ResultMessage<Object> pageBox(BoxSearchParams boxSearchParams) {
        return boxWinningRecordService.pageBox(boxSearchParams);
    }

    /**
     * 新增中奖记录
     */
    @PostMapping("/add")
    public ResultMessage<Object> addBoxGoods(@RequestBody BoxWinningRecordVO boxWinningRecordVO) {
        return boxWinningRecordService.addBoxGoods(boxWinningRecordVO);
    }

    /**
     * 中奖信息录入
     */
    @PostMapping("/informationEntry")
    public ResultMessage<Object> informationEntry(@RequestBody BoxWinningRecordVO boxWinningRecordVO) {
        return boxWinningRecordService.informationEntry(boxWinningRecordVO);
    }

    /**
     * 批量删除中奖记录
     */
    @DeleteMapping("/delete")
    public ResultMessage<Object> deleteBoxGoods(@RequestParam String ids) {
        return ResultUtil.data(boxWinningRecordService.removeBatchByIds(Collections.singletonList(ids.split(","))));
    }

    /**
     * 修改中奖记录
     */
    @PutMapping("/update")
    public ResultMessage<Object> updateBoxGoods(@RequestBody BoxWinningRecordVO boxWinningRecordVO) {
        return boxWinningRecordService.updateBoxGoods(boxWinningRecordVO);
    }

}
